<!-- 我的车位  车位申请 -->

<template>
	<view>

		<view class="tab-container bg-white margin-top">
			<view class="cu-list menu" v-if="rooms.length > 0">
				<view class="block__title">车位信息</view>

				<view class="cu-item arrow" v-for="(item, key) in rooms" :key="key" :data-item="item"
					@click="myHouseDetail(item)">
					<view class="content padding-tb-sm">
						<view>
							<text class="cuIcon-homefill text-green margin-right-xs"></text>
							业主 {{plotCommunityId}}
						</view>
						<view class="text-gray text-sm">
							<text class="cuIcon-right margin-right-xs">小区</text> {{communityName}}
						</view>
						<view class="text-gray text-sm">
							<text class="cuIcon-right margin-right-xs">车位名称</text> {{item.psName}}
						</view>
						<view class="text-gray text-sm">
							<text class="cuIcon-right margin-right-xs">车牌号</text> {{item.plate}}
						</view>
						<view class="text-gray text-sm" v-if="item.propertyType == 1">
							<text class="cuIcon-right margin-right-xs">产权类型</text> 已售
						</view>
						<view class="text-gray text-sm" v-if="item.propertyType == 2">>
							<text class="cuIcon-right margin-right-xs">产权类型</text> 未售
						</view>
						<view class="text-gray text-sm" v-if="item.propertyType == 3">
							<text class="cuIcon-right margin-right-xs">产权类型</text> 出租
						</view>

					</view>
					<view class="action">

						<view class="action_title" v-if="item.status == '通过'">
							已绑定
						</view>
						<view class="action_title" v-if="item.status == '进行中'">
							申请中
						</view>

						<!-- 					<view class="action_title" v-if="item.status == 'ZERO'">
							申请中
						</view>
						<view class="action_title" v-if="item.status == 'ONE'">
							已绑定
						</view>
						<view class="action_title" v-if="item.type == 2">
							审批中
						</view> -->
					</view>
				</view>

				<view class="cu-item" v-if="rooms.length === 0">
					<view class="content">
						<text class="cuIcon-warn text-green"></text>
						<text class="text-grey">暂无车位信息</text>
					</view>
					<view class="action">

					</view>
				</view>
			</view>

			<view v-else>
				<no-data-page></no-data-page>
			</view>

			<view class="bindHandle">
				<button @click="bindApplication(parkNumber)" type="primary">关联车牌号</button>
			</view>
		</view>

	</view>
</template>

<script>
	import context from '../../lib/java110/Java110Context.js';
	const constant = context.constant;
	import noDataPage from '@/components/no-data-page/no-data-page.vue'

	export default {
		data() {
			return {
				userId: "",
				rooms: "",
				communityName: '',
				plotCommunityId: '',
				identityType: '',
				bindState: '',
				parkNumber: '',
				carPsId: '',
				carName: ""
			};
		},

		components: {
			noDataPage
		},
		props: {},

		/**
		 * 生命周期函数--监听页面加载
		 */
		onLoad(options) {
			this.parkNumber = JSON.parse(options.parkNumber);
			this.carPsId = this.parkNumber.examineObjectId
			this.carName = this.parkNumber.examineObjectName
			console.log("车位编号111", this.carPsId, this.carName)
			this.plotCommunityId = uni.getStorageSync("plotCommunityId");
			let identity = uni.getStorageSync("bindUserInfo");
			this.identityType = identity.proprietorRole;
			this.bindState = identity.bindState
			this.loadMyCar()
		},

		/**
		 * 生命周期函数--监听页面初次渲染完成
		 */
		onReady: function() {},

		/**
		 * 生命周期函数--监听页面显示
		 */
		onShow: function() {
			this.loadMyCar()
			let _plotNum = uni.getStorageSync("_selectCommunity");
			// this.plotNum = _plotNum.communityName + "小区";

			if (_plotNum != null && _plotNum != undefined && _plotNum != '') {
				this.communityName = _plotNum.communityName + "小区";
				console.log("小区ID", this.plotCommunityId)
			}
		},

		/**
		 * 生命周期函数--监听页面隐藏
		 */
		onHide: function() {},

		/**
		 * 生命周期函数--监听页面卸载
		 */
		onUnload: function() {},

		/**
		 * 页面相关事件处理函数--监听用户下拉动作
		 */
		onPullDownRefresh() {
			this.loadMyCar()
		},

		/**
		 * 页面上拉触底事件的处理函数
		 */
		onReachBottom: function() {},

		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {},
		methods: {
			loadMyCar: function() {
				let userIdName = uni.getStorageSync("commonUser");
				this.userId = userIdName.id
				uni.request({
					url: constant.url.mineCarNumber,
					header: context.getHeaders(),
					method: "GET",
					data: {
						communityId: this.plotCommunityId,
						proprietorId: this.userId, //业主id
						// status: 0,
					},
					success: (res) => {
						this.rooms = res.data.result
						if (this.rooms.length < 1) {
							this.noData = true;
						}
					},
					fail: function(e) {
						wx.showToast({
							title: "服务器异常了",
							icon: 'none',
							duration: 2000
						});
					}
				});
			},

			// 车位详情-解绑
			myHouseDetail: function(_item) {
				uni.navigateTo({
					url: './changeCarNumber?room=' + JSON.stringify(_item)
				});
			},
			bindApplication: function(parkNumber) {
				uni.navigateTo({
					url: '../applyparking/addCarNumber?car=' + JSON.stringify(parkNumber)
					// url: './parkingInfo?room=' + JSON.stringify(_item)
				});
			}
		}
	};
</script>
<style scoped lang="scss">
	@import "@/pagesB/my/myHouse.css";

	.margin-top {
		margin-top: 0rpx;
	}

	.block__title {
		margin: 0;
		font-weight: 400;
		font-size: 14px;
		color: rgba(69, 90, 100, .6);
		padding: 40rpx 30rpx 20rpx;
	}

	.cu-list {
		width: 100%;
		overflow: auto;
		background-color: white;
		height: calc(100vh - 100rpx);

		.cu-item {
			background-color: #F5F5F5;
			margin: 20rpx 20rpx;
			border-radius: 30rpx;
		}
	}

	.bindHandle {
		width: 100%;
		height: 100rpx;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		justify-content: center;
		background-color: aliceblue;

		button:nth-child(1) {
			margin: 15rpx;
			width: 400rpx;
			height: 70rpx;
			border-radius: 40rpx;
			font-size: 26rpx;
			line-height: 70rpx;
		}
	}
</style>
